PHYSICAL
DATA
ORGANIZATION FUNDAMENTALS. SPACE MAPS PART-2
In this article I will try and explain the basic difference
between a segmented table space spacemap page and a simple table space
spacemap page.
I have kept minor details off this write up to be able to hilite the
basic differences. Before you read this article it would be
beneficial if you read PART-1.
A space map page of a partitioned and a simple table space are almost
identical. In this article, I will be referring to the simple and
partitioned space map pages as "non-segmented".
The basic structure and function of a Segmented space map page and a
non-segmented space map page are the same. They both
contain two types of information
(a) Information about how much space is available in each page in
it's range.
(b) Information about which pages in it's range have changed
since the last image copy.

So, what is the difference between a segmented and a non-segmented
space map page?
The first difference between them lies in the level of detail of
information stored about the amount of space
available in each data page. In a segmented table space the information
about each page in it's range is much richer than in a non-segmented
table space. In other words, in a segmented tableapce there is
more information about each page in it's range as compared to a
non-segmented table space.
The second difference lies in the very structure of space map
page where each group of space map entries that
belong to a segment are grouped together.


Each space map entry in a segmented table space is represented by
4 bits while that of a non-segmented table space is represented by 2
bits. So what does it actually mean?
Imagine that I am sitting inside a room with no windows and ask
you a simple question such as "Is it raining outside?".
However I want you to use a maximum of three alphabets to answer
my question, you can answer with either a "YES" or "NO ".
If it is just drizzling outside, you are still going to answer
with a "YES". If it is about to rain and not raining at present
you are going to answer "NO ". If there is a
hurricane about to kill all of us you are still going to
answer with a "YES".
On the other hand if I allow you 500 alphabets to answer the same
question you might come back and say " YES, IT IS RAINING AND THERE IS
A HURRICANE COMING OUR WAY. RUN FOR YOUR LIFE,YOU FOOL!!! " or
" NO, IT IS NOT RAINING. ACTUALLY IT IS A GOOD DAY FOR A PICNIC".
So it is obvious that more the number of alphabets I allow you to use
in your answers, the richer and more useful the information will be.
Similarly space information in the space map page represented by
4 bits instead of just 2 bits is much richer and tells us more about
the amount of space available in a given page.
In a non-segmented table space the two bits that are used to represent
space information are used as follows.
If the two bits in the space map page for a given page is
'00' - The space available in the page is greater than or equal to the
maximum size of the record (ample space)
'01' - The space available in the page is greater than or equal to the
average size of the record and lesser than the maximum size of the
record
'10' - The space available in the page is greater than or equal to the
minimum size of the record and lesser than the average size of the
record
'11' - The space available in the page is less than the minimum size
of the record (no space)
In a segmented table space the four bits that are used to represent
space information are used as follows.
If the four bits in the space map page for a given page is
'0000' - The page is empty and unformatted
'0001' - The page is empty due to mass delete
'0010' - The page is empty due to mass delete
'0011' - The page has enough space to accommodate the largest record
'0100 through 1010' - convert binary 'xxxx' into a decimal number
'n'. For example '0100' would be 4 and '0101' would be 5. '1010'
would be 10. Then the amount of space available on that page is lesser
than (The maximum size of the record - (n - 4) x INTEGER((maximum rec
size - minimum rec size)/8) )
and greater than
(The maximum size of the record - (n - 3) x INTEGER((maximum rec size -
minimum rec size)/8) )
'1011' - amount of space available on that page is lesser than
(The maximum size
of the record - 7 x INTEGER((maximum rec size - minimum rec
size)/8) ) and greater than the minimum size of the record.
'1111' - Page is full.
Now, what is all this talk about maximum record size and average record
size and minumum record size. All that comes into play only if
any of
your columns are VARCHAR. If none of your columns are VARCHAR, then
average record length equals maximum record length equals minimum
record length.
I am sure it is evident by now that four bits can represent more
information about the space available as compared to two bits.
On the other hand since more space is used up for each entry by a
segmented table space (4 bits) as compared to a non segmented table
space (2 bits), the range of a segmented space map page is lesser than
that of a non-segmented space map page. (remember how if Mr.Chang
started recording more information on his "map sheet" he cannot store
information about a lot of tables in one sheet ).
An other minor difference between segmented and non segmented space map
page is that in a segmented space map page the space map entries of
each segment is grouped together. This is because each segment can hold
data from only table and it is much more convenient to group them
together.